//
//  WlisLoginRegisterVC.swift
//  Swift_missScarlett
//
//  Created by xmg on 16/8/13.
//  Copyright © 2016年 wlis. All rights reserved.
//

import UIKit

class WlisLoginRegisterVC: UIViewController {

    /** 底部View */
    @IBOutlet weak var bottomView: UIView!
    /** 中间View */
    @IBOutlet weak var midstView: UIView!
    /** 设置约束移动先 */
    @IBOutlet weak var leadConst: NSLayoutConstraint!
    override func viewDidLoad() {
        super.viewDidLoad()

        let loginV = WlisLoginRegisterV.loginView();
        midstView.addSubview(loginV)
        midstView.translatesAutoresizingMaskIntoConstraints = false
        let registerV = WlisLoginRegisterV.registerView();
        midstView.addSubview(registerV)
        /** 添加快速登陆View */
        let fastLoginV = WlisFastLoginV.fastLoginView();
        fastLoginV.frame = self.bottomView.bounds;
        bottomView.addSubview(fastLoginV);
        
    }

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews();
        /** 设置尺寸 */
        let loginV = midstView.subviews[0];
        loginV.frame = CGRectMake(0, 0, midstView.frame.size.width * 0.5, midstView.frame.size.height)
        /** 设置尺寸 */
        let registerV = midstView.subviews[1];
        registerV.frame = CGRectMake(midstView.frame.size.width * 0.5, 0, midstView.frame.size.width * 0.5, midstView.frame.size.height);
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    @IBAction func goBlackBtnClick(sender: AnyObject) {
        self.dismissViewControllerAnimated(true, completion: nil);
    }

    @IBAction func loginBtnClick(sender: UIButton) {
        sender.selected = !sender.selected;
        /** 三目设置位置的宽度 */
        leadConst.constant = (leadConst.constant == 0) ? -midstView.frame.size.width * 0.5 : 0
        /** 设置动画 */
        UIView.animateWithDuration(0.25) { () -> Void in
            self.view.layoutIfNeeded();
        }
        
    }

}
